using System.Text.Json.Serialization;

namespace net_work.Common.Request;

public class FilterCondition
{
    public FilterCondition(string propertyName, FilterOperator @operator, object value)
    {
        PropertyName = propertyName;
        Operator = @operator;
        Value = value;
    }

    public FilterCondition()
    {
    }

    /// <summary>
    /// 属性名
    /// </summary>
    public string PropertyName { get; set; } = null!;

    /// <summary>
    /// 操作符
    /// </summary>
    public FilterOperator Operator { get; set; } = FilterOperator.Equals;

    /// <summary>
    /// 值
    /// </summary>
    [JsonConverter(typeof(FilterConditionValueConverter))]
    public object Value { get; set; } = null!;
}

// 定义操作符枚举
public enum FilterOperator
{
    /// <summary>
    /// 等于
    /// </summary>
    Equals,

    /// <summary>
    /// 不等于
    /// </summary>
    NotEquals,

    /// <summary>
    /// 大于
    /// </summary>
    GreaterThan,

    /// <summary>
    /// 小于
    /// </summary>
    LessThan,

    /// <summary>
    /// 模糊匹配
    /// </summary>
    Like,

    /// <summary>
    /// 以...开头
    /// </summary>
    StartsWith,

    /// <summary>
    /// 以...结尾
    /// </summary>
    EndsWith,
    
    /// <summary>
    /// 包含于集合中
    /// </summary>
    In
}